package geektime.spring.studentdemo;

import geektime.spring.studentdemo.mapper.StudentMathMapper;
import geektime.spring.studentdemo.model.StudentMath;
import geektime.spring.studentdemo.utils.BitMapUtils;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;

@SpringBootApplication
@Slf4j
@MapperScan("geektime.spring.studentdemo.mapper")
public class StudentMathApplication implements ApplicationRunner {

    @Autowired
    private StudentMathMapper studentMathMapper;

    public static void main(String[] args) {
        SpringApplication.run(StudentMathApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {

        //分数排名
        studentMa();
        //bitmap去重
        bitMapTest();
        //log.info("studentMath: {}", list);
    }

    public void studentMa(){
        List<StudentMath> list=studentMathMapper.findAll();
        log.info("分数排名结果,{}",list);
    }

    public void  bitMapTest() {
        int n = 101;
        byte[] bits =  BitMapUtils.create(n);
        log.info("call  检测是否包含其中 ：{}", BitMapUtils.contains(bits,100));
    }
}
